using UnityEngine;
using System.Collections;

public class FinalMovement : MonoBehaviour {

    public Transform target;

    public float time;

    public string nextScene;

    private bool skip;

    IEnumerator Start()
    {
        rigidbody.isKinematic = true;
        iTween.MoveTo(gameObject, new Vector3(target.position.x, target.position.y, transform.position.z), time);
        yield return new WaitForSeconds(5);
        skip = true;
    }

    void Update()
    {
        if (Input.anyKeyDown)
        {
            if (skip && !string.IsNullOrEmpty(nextScene))
            {
                gameObject.AddComponent("SceneChange");

                if (gameObject.GetComponent<SceneChange>().existFade())
                {
                    gameObject.GetComponent<SceneChange>().createFade(nextScene, 3);
                }

                skip = false;
            }
        }
    }
}
